<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<li class="peer_review <%= request.try_rescue(:workflow_state) || 'assigned' %>" id="review_request_<%= request ? request.id : 'blank' %>" style="<%= hidden unless request %>">
  <span style="float: left;">
    <% if request && request.completed? %>
      {{> icons/check}}
      <span class="screenreader-only"><%= I18n.t("Finished") %></span>
    <% end %>
    <% if (request && !request.completed?) || request.nil? %>
      {{> icons/warning}}
      <span class="screenreader-only"><%= I18n.t("Assessment not yet Completed") %></span>
    <% end %>
    <a href="<%= context_url(@context, :context_assignment_submission_url, @assignment.id, request ? request.asset.user_id : '{{ user_id }}') %>">
      <span class="asset_user_name"><%= request.try_rescue(:asset).try_rescue(:user).try_rescue(:last_name_first) || nbsp %></span>
    </a>
  </span>
  <span class="user_id" style="display: none;"><%= request.try_rescue(:asset).try_rescue(:user_id) || nbsp %></span>
  <div style="float: right;" class="review_links">
    <% user = request.try_rescue(:assessor).try_rescue(:name)
       user ||= t 'titles.user_default', "User"
       reminder = t 'titles.remind_reviewer', "Remind %{user} about Assessment", :user => user
       reminder = t 'titles.remind_reviewier_with_last_notification', "Remind %{user} about Assessment, last notified %{at}", :user => user, :at => datetime_string(request.updated_at) if request && request.assigned?
    %>
    <a
      class="remind_peer_review_link no-hover"
      style="<%= hidden if request && request.completed? %>"
      href="<%= context_url(@context, :context_assignment_remind_peer_review_url, @assignment.id, request ? request.id : '{{ id }}') %>">
      <span class="screenreader-only"><%= reminder %></span>
      {{> icons/alerts}}
    </a>
    <a
      class="delete_review_link no-hover"
      href="<%= context_url(@context, :context_assignment_delete_peer_review_url, @assignment.id, request ? request.id : '{{ id }}') %>">
      <span class="screenreader-only">{{#t}}Delete{{/t}}</span>
      {{> icons/trash}}
    </a>
  </div>
  <div class="clear"></div>
</li>
